#include "multiboot.hpp"
#include "vga.hpp"
#include "system.hpp"
#include "idt.hpp"
#include "keyboard.hpp"
#include "cpuexceptions.hpp"

extern "C" void kernel_main(multiboot_header *mbh, unsigned int magic_number){

    vga::printf("###w#0f00###t-os [version 0.0.2]\nCopyright 2010 - BosByte\n\n--------------------------------------------------------------------------------\n");

    vga::printf("###"
        "                             #0f \xDC\xDB\xDC   \xDC\xDB\xDC ###                   \n"
        "                             #0f\xDC\xDB\xDF\xDB\xDC \xDC\xDB\xDF\xDB\xDC###                   \n"
        "                     \xDC\xDC   \xDC\xDC #0f\xDB\xDB \xDB\xDB \xDB\xDB \xDB\xDB### \xDC\xDC                \n"
        "                     \xDB\xDB   \xDB\xDB #0f\xDB\xDB \xDB\xDB \xDB\xDB \xDB\xDB### \xDB\xDB\xDC\xDC      ###\xDC\xDF\xDF\xDC \xDC\xDF\xDF###\n"
        "                     \xDB\xDB   \xDB\xDB #0f\xDB\xDB \xDB\xDB \xDB\xDB \xDB\xDB### \xDB\xDB    ###\xDC\xDC\xDC ###\xDB  \xDB \xDF\xDC ###\n"
        "                     \xDB\xDB \xDB \xDB\xDB #0f\xDF\xDB\xDC\xDB\xDF \xDF\xDB\xDC\xDB\xDF### \xDB\xDB  \xDC     ###\xDB  \xDB   \xDB###\n"
        "                      \xDB\xDB\xDF\xDB\xDB  #0f \xDF\xDB\xDF   \xDF\xDB\xDF ### \xDF\xDF\xDB\xDB\xDF     ### \xDF\xDF  \xDF\xDF ###\n");

    vga::printf("\n--------------------------------------------------------------------------------\n");

    new keyboard_handler();

    system::enable_interrupts();

    vga::printf("Entering infinite loop . . . \n");

    while(true);

    vga::printf("Inifinte loop appears to be finished, this must be a really fast cpu.\n");

    asm volatile(""::"a"(0xBADC0DE0),"b"(0xEEEEEEEE),"c"(0), "d"(0), "S"(0), "D"(0));
    crash();

}
